﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace 转发程序
{
    /// <summary>
    /// MainWindow.xaml 的交互逻辑
    /// </summary>
    public partial class MainWindow : Window
    {
        /// <summary>
        /// 转发服务
        /// </summary>
        转发程序.转发服务.SerPorcess serProce = new 转发程序.转发服务.SerPorcess();

        public MainWindow()
        {
            InitializeComponent();

            Title =Title+ " 邦定端口:" + System.Configuration.ConfigurationManager.AppSettings["邦定端口"];
        }

        /// <summary>
        /// 启动转发服务
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void button1_Click(object sender, RoutedEventArgs e)
        {
            转发程序.AsyncSocketServer.AsyncSocketServer server = new AsyncSocketServer.AsyncSocketServer(new System.Net.IPEndPoint(System.Net.IPAddress.Any, 4000));
            server.Start();
            if (button1.Content+"" == "停止服务")
            {
                //停止服务
                serProce.Stop();
                button1.Content = "启动服务";
            }
            else
            {
                //启动服务
                serProce.Process();
                button1.Content = "停止服务";
            }
        }
    }
}
